package com.sl.mes.app.controller;

import com.mysql.jdbc.log.Log;
import com.sl.mes.app.dao.agg.AggMaterial;
import com.sl.mes.app.service.UserInfoService;
import com.sl.mes.db.service.bd.BdMaterialService;
import com.sl.mes.db.service.pd.PdWkgMarService;
import com.sl.mes.db.vo.BdMaterial;
import com.sl.mes.db.vo.PdWkgMar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 单晶传参
 */
@RestController
@RequestMapping("/mes/mat")
@Validated
public class MesMaterialController {
    private static final Logger logger = LoggerFactory.getLogger(MesAuthController.class);
    @Autowired
    private UserInfoService userInfoService;
    @Resource
    private PdWkgMarService pdWkgMarService;

    /**
     * 查询所有物料基本信息并分页
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/queryAll")
    public List<AggMaterial> queryAll(Integer pageNo, Integer pageSize){
        List<AggMaterial> materials = userInfoService.queryAllLimit(pageNo, pageSize);

        return materials;
    }

    /**
     *根据pk_marbasclass分类并分页
     * @param pk_marbasclass
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/queryAllByMarbasclass")
    public List<AggMaterial> queryAllByMarbasclass(String pk_marbasclass, Integer pageNo, Integer pageSize){
        List<AggMaterial> materials = userInfoService.queryAllByCode(pk_marbasclass, pageNo, pageSize);
        return materials;
    }

    /**
     * 根据pk_wkg_mar查询物料及物料分类及分页
     * @param pk_wkg_mar
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/queryByPkWkgMar")
    public List<PdWkgMar> queryByPkWkgMar(String pk_wkg_mar, Integer pageNo, Integer pageSize){
        List<PdWkgMar> lst= null;
        try {
            lst = pdWkgMarService.queryByWkgMar(pk_wkg_mar,pageNo,pageSize);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            logger.info("参数不正确");
        }
        return lst;
    }
}
